package cn.yunhe.controller;

import cn.yunhe.entity.Goods;
import cn.yunhe.service.IGoodsService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/after/QueryAllGoodsServlet")
public class QueryAllGoodsServlet extends HttpServlet {

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        IGoodsService iGoodsService=new IGoodsService();
           int count=iGoodsService.getCount();
        List<Goods> glist=iGoodsService.queryAllGoods();
        request.setAttribute("glist",glist);
        request.setAttribute("count",count);
          request.getRequestDispatcher("product-list.jsp").forward(request,response);
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doPost(req, resp);
    }
}
